#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <p style="float:right">
                        #(form.select.islog)
                        <input type="text" id="act_path" placeholder="活动路经" class="table-search-text width300"/>
                        <input type="text" id="act_role" placeholder="活动角色" class="table-search-text width120"/>
                        <input type="text" id="act_user" placeholder="活动用户" class="table-search-text width120"/>
                        <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                            搜索
                        </button>

                    </p>
                    <i class="layui-icon layui-icon-triangle-r"></i>
                    当前位置 > <span class="color_green">事务活动列表</span>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container">
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="EditSysActivity">修改活动</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-del" lay-event="DelSysActivity">删除</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-change-13" lay-event="SetActivityRole">配置角色</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-change-14" lay-event="SetActivityUser">配置人员</button>
                        </div>
                    </script>
                    <script type="text/html" id="temp_is_log">
                        <input type="checkbox" lay-skin="primary" field="is_log" msg="设置记录日志" value="{{d.act_id}}" lay-filter="ChangeTag" {{ d.is_log ? 'checked' : '' }}>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">
    layui.use(['myTable', 'table', 'form', 'util', 'myTool', 'drawer'], function () {
        var $ = layui.$, myTable = layui.myTable, myTool = layui.myTool;
        /**
         * 表格
         */
        tableindex = layui.myTable.render({
            elem: '#table_1', url: 'SysActivityListDataApi'
            , title: '列表'
            , where: {}
            , cols: [[
                {type: 'checkbox', width: 36}
                , {field: 'act_id', title: '活动ID', width: 80, align: 'center', sort: true}
                , {field: 'act_name', title: '活动名称', width: 180, edit: 'text'}
                , {field: 'act_path', title: '活动路经', width: 320}
                , {field: 'html_role', title: '角色（权限）', width: 300}
                , {field: 'html_user', title: '人员（权限）', width: 200}
                , {field: 'act_desc', title: '备注'}
                , {field: 'is_log', title: '记录日志', width: 80, align: 'center', templet: '#temp_is_log'}

            ]]
            , page: true, limit: 10
            , serviceSort: true, initSort: {field: 'act_id', type: 'desc'}
            , editField: {url: 'ModifySysActivityFieldApi', key: 'act_id'}
        });


        /**
         * 按钮事件
         */
        layui.util.event("lay-event", {
            DoSearch: function () {
                tableindex.config.where = {like: {act_role_name: $("#act_role").val(), act_user_name: $("#act_user").val(),act_path: $("#act_path").val()}, s: { is_log: $("#is_log").val()}};
                tableindex.reload({where: tableindex.config.where, page: {curr: 1}});
            }
            , DoSearchMore: function () {
                layui.form.render();
                drawer1.open();
            }
        });

        /**
         * 工具栏事件
         */
        layui.table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                SetActivityRole: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '100px', area: ['600px', '450px'], title: ['配置活动角色', 'font-size:15px;'],
                            content: ["sysactivity/SetActivityRole?act_id=" + data[0].act_id, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , SetActivityUser: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '100px', area: ['600px', '450px'], title: ['配置事务活动人员', 'font-size:15px;'],
                            content: ["sysactivity/SetActivityUser?act_id=" + data[0].act_id, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , EditSysActivity: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '60px', area: ['800px', '580px'], title: ['修改事务活动[' + data[0].act_id + ']', 'font-size:15px;'],
                            content: ["sysactivity/EditSysActivity?act_id=" + data[0].act_id, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , DelSysActivity: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.confirm('你是否确认删除事务活动【' + data[0].act_id + '】', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                            myTool.postMsg("DelSysActivityApi", {
                                act_id: data[0].act_id
                            }, function () {
                                top.layer.close(index2);
                                tableindex.reload();
                            });
                        });
                    });
                }
            });
        });
        layui.form.on('checkbox(ChangeTag)', function (obj) {
            myTool.postMsg("ChangeTagApi", {key: this.value, field: $(obj.elem).attr("field"), msg: $(obj.elem).attr("msg")}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
        layui.form.on('switch(ChangeTag)', function (obj) {
            myTool.postMsg("ChangeTagApi", {key: this.value, field: $(obj.elem).attr("field"), msg: $(obj.elem).attr("msg")}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
    });
</script>
#include("../../comm/Foot.html")